import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/utils/component/list/table_view.dart';
import 'package:leader_help/utils/util.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class IndustryPage extends StatelessWidget {
  IndustryPage({Key? key}) : super(key: key);
  final controller = Get.put(IndustryController());
  final state = Get.find<IndustryController>().state;
  // 内容页
  Widget _buildView() {
    return TableView(
        padding: EdgeInsets.symmetric(horizontal: 10.r),
        data: state.dataSource);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<IndustryController>(
      builder: (_) {
        return Scaffold(
          body: Container(
            color: Colors.white,
            margin: EdgeInsets.fromLTRB(10.r, 120.r, 10.r, 0),
            child: Column(
              children: [
                Container(
                  decoration: const BoxDecoration(
                    border: Border(
                      bottom:
                          BorderSide(color: ColorsUtil.separator, width: 0.5),
                    ),
                  ),
                  child: TabBar(
                      controller: state.tabCtrl,
                      indicatorColor: ColorsUtil.red,
                      labelColor: ColorsUtil.red,
                      unselectedLabelColor: ColorsUtil.title,
                      indicatorSize: TabBarIndicatorSize.label,
                      tabs: state.titles
                          .map((e) => Tab(
                                text: e,
                              ))
                          .toList()),
                ),
                Expanded(
                  child: _buildView(),
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}
